import {Component} from '@angular/core';
import {GnTable} from "geminis-ng";
import {GnTableColumn} from "geminis-ng/data/table.component";
import {ActivatedRoute, Router} from "@angular/router";
import {JWTService} from "geminis-ng-resources";
import {ModellerComponent} from "../modeller/modeller.component";

@Component({
  selector: 'gn-workflow-manager-model-list',
  templateUrl: './model-list.component.html'
})
export class ModelListComponent extends GnTable {

  columns: GnTableColumn[] = [
    {label: '编号', field: 'key'},
    {label: '名称', field: 'name'}
  ];

  typeDesign = ModellerComponent;

  constructor(private router: Router,
              private route: ActivatedRoute,
              private jwtService: JWTService) {
    super();
  }

  delete(): void {
    this.table.deleteData(this.table.url,
      this.table.selection.selected
        .map(process => process.deploymentId)
    )
  }

  export(): void {
    this.jwtService.openWindow('/WORKFLOW-SERVICE/models/' + this.table.selectedId + '/bpmn');
  }

}
